package me.zhengjie.exception;

import org.springframework.util.StringUtils;

/**
 * Description: 实体不存在 .<br>
 *
 * @author jm
 * @since 2020/1/20
 */
public class EntityNotFoundException extends RuntimeException {

    public EntityNotFoundException(Class clazz, String field, String val) {
        super(EntityNotFoundException.generateMessage(clazz.getSimpleName(), field, val));
    }

    private static String generateMessage(String entity, String field, String val) {
        return StringUtils.capitalize(entity)
            + " with " + field + " " + val + " does not exist";
    }
}
